package com.winai.launcher.bean.db;

import org.litepal.crud.LitePalSupport;

import java.io.Serializable;

/**
 * 作者：康少
 * 时间：2019/12/13 0013
 * 说明：闹钟对象
 *
 * 重要！！！重要！！！重要！！！重要！！！
 * 属性！如果修改了，需要增加assets里面的litepal.xml里面的版本
 */
public class AlarmClockBean extends LitePalSupport implements Serializable {
    private String alarmId;//闹钟Id，默认以当前时间戳为id
    private String week;//星期几
    private int repeat;//二进制闹钟周期
    private String day;//年月日
    private String time;//时分
    private String remark;//备注说明
    private boolean isOpen = false;//是否打开状态
    private int alarmClockType = ONCE;

    /**
     * 周期性时间间隔的标志,ONCE 表示一次性的闹钟, EVERYDAY 表示每天提醒的闹钟(1天的时间间隔),
     * WEEK 表示按周每周提醒的闹钟（一周的周期性时间间隔）
     */
    public static final int ONCE = 0;
    public static final int EVERYDAY = 1;
    public static final int WEEK = 2;

    public String getId() {
        return alarmId;
    }

    public AlarmClockBean setId(String id) {
        this.alarmId = id;
        return this;
    }

    public String getWeek() {
        return week;
    }

    public AlarmClockBean setWeek(String week) {
        this.week = week;
        switch (week) {
            case "永不":
                this.repeat = 0;
                this.setAlarmClockType(ONCE);
                break;
            case "每天":
                this.repeat = 127;
                this.setAlarmClockType(EVERYDAY);
                break;
            case "工作日":
                this.repeat = 31;
                this.setAlarmClockType(WEEK);
                break;
            default:
                this.setAlarmClockType(WEEK);
                //二进制的值代表选中了的星期
                this.repeat = ((week.contains("星期一")) ? 1 : 0)
                        + ((week.contains("星期二")) ? 1 : 0) * 2
                        + ((week.contains("星期三")) ? 1 : 0) * 4
                        + ((week.contains("星期四")) ? 1 : 0) * 8
                        + ((week.contains("星期五")) ? 1 : 0) * 16
                        + ((week.contains("星期六")) ? 1 : 0) * 32
                        + ((week.contains("星期日")) ? 1 : 0) * 64;
                break;
        }
        return this;
    }

    public int getRepeat() {
        return repeat;
    }

    public String getDay() {
        return day;
    }

    public AlarmClockBean setDay(String day) {
        this.day = day;
        return this;
    }

    public String getTime() {
        return time;
    }

    public AlarmClockBean setTime(String time) {
        this.time = time;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public AlarmClockBean setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public boolean isOpen() {
        return isOpen;
    }

    public AlarmClockBean setOpen(boolean open) {
        isOpen = open;
        return this;
    }

    public int getAlarmClockType() {
        return alarmClockType;
    }

    public AlarmClockBean setAlarmClockType(int alarmClockType) {
        this.alarmClockType = alarmClockType;
        return this;
    }
}
